package com.gitee.wsl.io.dataproxy

class DataProxyWarp<T>(override val base: DataProxy<T>, indexList:List<Int>):
    DataGetWarp<T>(base,indexList), DataProxy<T> {
    constructor(base: DataProxy<T>, intRange: IntRange):this(base,intRange.toList())
    constructor(base: DataProxy<T>, vararg index:Int):this(base,index.toList())

    override fun fill(value: T, fromIndex: Int, toIndex: Int) = (fromIndex..toIndex).forEach { set(it,value) }

    override fun set(index: Int, value: T) {
        base[indexList[index]] = value
    }
}

fun<T> DataProxy<T>.asProxy(intRange: IntRange) = DataProxyWarp(this,intRange)

fun<T> DataProxy<T>.asProxy(vararg index:Int) = DataProxyWarp(this,*index)

fun<T> DataProxy<T>.asProxy( indexList: List<Int>) = DataProxyWarp(this,indexList)